package com.woshua.gsonmodel

import com.google.gson.Gson
import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import java.lang.reflect.Type
import java.util.*
import kotlin.collections.ArrayList

/**
 * @author Steven.zhao
 * email:hongtu.zhao@goodwinsoft.net
 * date:2019/7/23
 * desc:
 */
class ArraySecurityAdapter:JsonDeserializer<List<*>> {
    override fun deserialize(json: JsonElement, typeOfT: Type?, context: JsonDeserializationContext?): List<*> =
            if(json.isJsonArray)
            {
                val newGson=Gson()
                newGson.fromJson(json,typeOfT)
            }
            else
            {
                ArrayList<Any>()
            }
}